package oop.core.visitors;

import oop.core.item.*;
import oop.core.entity.*;
import oop.core.map.*;

import java.util.*;

/**
 * Class in charge of visiting specific Takeable
 * Item types: Useable, OneShot, Equippable.
 * @author DangMH
 *
 */
public class PickUpVisitor
{
	private Avatar avatar;
	private Map<Location, TakeableItem> map;
	
	public PickUpVisitor(Avatar avatar, Map map)
	{
		this.avatar = avatar;
		this.map = map;
	}
	
	/**
	 * Operation to add picked up equipment to the Avatar's equipment
	 * @param item
	 */
	public void visitEquippableItem(EquippableItem item)
	{
		if(avatar.addItem(item))
		{
			map.remove(avatar.getLoc());
		}	
	}
	
	/**
	 * Operation to add picked up usable item to the Avatar's equipment
	 * @param item
	 */
	public void visitUsableItem(UsableItem item)
	{
		if(avatar.addItem(item))
		{
			map.remove(avatar.getLoc());
		}
	}
	
	/**
	 * Operation to pass the oneShotItem to the useVisitor for instant use
	 * @param item
	 */
	public void visitOneShotItem(OneShotItem item)
	{
		UseVisitor v = new UseVisitor(avatar);
		v.visitOneShotItem(item);
		map.remove(avatar.getLoc());
	}
	
	/**
	 * Operation to add picked up quest item into Avatar's inventory
	 * @param item
	 */
	public void visitQuestItem(QuestItem item)
	{
		if(avatar.addItem(item))
		{
			map.remove(avatar.getLoc());
		}
	}
	
}